<template>

  <el-container id="Resume" direction="vertical">
    <el-main id="seeker" v-for="(seek, index) in seeker">
      <h1><i class="el-icon-s-custom"></i> 个人信息</h1>
      <div>
        <el-button type="primary" class="edit-button" plain @click="openEditSeekerDialog(index)">编辑</el-button>
        <el-dialog title="个人信息" :visible.sync="editSeekerVisible" center>
          <el-form :model="editSeeker">
            <el-form-item label="姓名" :label-width="'120px'">
              <el-input v-model="editSeeker.seekerName"></el-input>
            </el-form-item>
            <el-form-item label="密码" :label-width="'120px'">
              <el-input v-model="editSeeker.password"></el-input>
            </el-form-item>
            <el-form-item label="性别" :label-width="'120px'">
              <el-select v-model="editSeeker.seekerGender">
                <el-option label="男" value="男"></el-option>
                <el-option label="女" value="女"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="生日" :label-width="'120px'">
              <el-date-picker
                  v-model="editSeeker.seekerBirthday"
                  type="date">
              </el-date-picker>
            </el-form-item>
            <el-form-item label="所在地" :label-width="'120px'">
              <el-cascader
                  :options="province"
                  v-model="editSeeker.seekerLocation"
                  :show-all-levels="false"
                  filterable
                  @change="handleLocationChange"
              ></el-cascader>
            </el-form-item>
            <el-form-item label="籍贯" :label-width="'120px'">
              <el-cascader
                  :options="home"
                  v-model="editSeeker.seekerHome"
                  :show-all-levels="false"
                  filterable
                  @change="handleHomeChange"
              ></el-cascader>
            </el-form-item>
            <el-form-item label="电话" :label-width="'120px'">
              <el-input v-model="editSeeker.tel"></el-input>
            </el-form-item>
            <el-form-item label="微信" :label-width="'120px'">
              <el-input v-model="editSeeker.seekerWechat"></el-input>
            </el-form-item>
            <el-form-item label="邮箱" :label-width="'120px'">
              <el-input v-model="editSeeker.seekerEmail"></el-input>
            </el-form-item>
          </el-form>
          <span slot="footer" class="dialog-footer">
            <el-button type="primary" @click="editSeekerToBackend">确 定</el-button>
            <el-button @click="editSeekerVisible = false">取消</el-button>
          </span>
        </el-dialog>
      </div>
      <div id="seekerName">
        {{seek.seekerName}}
      </div>
      <br>
      <div id="seekerInfo">
        性别：{{seek.seekerGender}}
        年龄：{{calculateAge(seek.seekerBirthday)}}岁
        所在地：{{seekerCity}}
        籍贯：{{seekerHomeTown}}
        <br><br>
      </div>
      <i class="el-icon-mobile-phone"> {{seek.tel}}</i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <i class="el-icon-chat-dot-round"> {{seek.seekerWechat}}</i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <i class="el-icon-message"> {{seek.seekerEmail}}</i>
    </el-main>

    <el-main id="intention">
      <h1><i class="el-icon-s-promotion"></i> 求职意向</h1>
      <el-button type="primary" round @click="addIntentionVisible = true">添加求职意向</el-button>
      <el-dialog title="求职意向" :visible.sync="addIntentionVisible" center>
        <el-form :model="addIntention">
          <el-form-item label="期望职位" :label-width="'120px'">
            <el-cascader
                placeholder="选择职位"
                :options="industry"
                v-model="addIntention.intentionOccupation"
                :key="industry.industryId"
                :label="industry.industryName"
                :children="industry.categories"
                :show-all-levels="false"
                filterable
                @change="handleCategoryChange"
            ></el-cascader>
          </el-form-item>
          <el-form-item label="期望城市" :label-width="'120px'">
            <el-cascader
                placeholder="选择城市"
                :options="province"
                v-model="addIntention.intentionCity"
                :show-all-levels="false"
                filterable
                @change="handleProvinceChange"
            ></el-cascader>
          </el-form-item>
          <el-form-item label="期望薪资" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addIntention.intentionSalary" placeholder="输入期望薪资"></el-input>
            </el-col>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="addIntentionToBackend">确 定</el-button>
          <el-button @click="addIntentionVisible = false">取消</el-button>
        </span>
      </el-dialog>
      <div id="intend" v-for="(intend,index) in intention">
        <div>
          <el-button type="primary" class="edit-button" plain @click="openEditIntentionDialog(index)">编辑</el-button>
          <el-dialog title="求职意向" :visible.sync="editIntentionVisible" center>
            <el-form :model="editIntention">
              <el-form-item label="期望职位" :label-width="'120px'">
                <el-cascader
                    :options="industry"
                    v-model="editIntention.intentionOccupation"
                    :key="industry.industryId"
                    :label="industry.industryName"
                    :children="industry.categories"
                    :show-all-levels="false"
                    filterable
                    @change="handleCategoryChange"
                ></el-cascader>
              </el-form-item>
              <el-form-item label="期望城市" :label-width="'120px'">
                <el-cascader
                    :options="province"
                    v-model="editIntention.intentionCity"
                    :show-all-levels="false"
                    filterable
                    @change="handleProvinceChange"
                ></el-cascader>
              </el-form-item>
              <el-form-item label="期望薪资" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editIntention.intentionSalary"></el-input>
                </el-col>
              </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
              <el-button type="primary" @click="editIntentionToBackend">确 定</el-button>
              <el-button @click="editIntentionVisible = false">取消</el-button>
            </span>
          </el-dialog>
        </div>
        <div id="intentionOccupationName">
          {{intend.intentionOccupationName}}
        </div>
        <br>
        <i class="el-icon-location-outline"> 期望城市：{{intend.intentionCityName}}</i>
        <br>
        <div>
          <el-button type="danger" icon="el-icon-delete" circle class="edit-button" @click="deleteIntention(index)"></el-button>
        </div>
        <br>
        <i class="el-icon-money"> 薪资要求：{{intend.intentionSalary}}</i>
      </div>
    </el-main>

    <el-main id="education">
      <h1><i class="el-icon-s-home"></i> 教育经历</h1>
      <el-button type="primary" round @click="addEducationVisible = true">添加教育经历</el-button>
      <el-dialog title="教育经历" :visible.sync="addEducationVisible" center>
        <el-form :model="addEducation">
          <el-form-item label="就读学校" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addEducation.school" placeholder="输入学校名称"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="学历" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addEducation.educationDegree" placeholder="输入学历"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="所学专业" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addEducation.major" placeholder="输入专业名称"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="就读时间" :label-width="'120px'">
            <el-date-picker
                v-model="addEducation.educationStart"
                type="date"
                placeholder="选择开始日期">
            </el-date-picker>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <el-date-picker
                v-model="addEducation.educationEnd"
                type="date"
                placeholder="选择结束日期">
            </el-date-picker>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="addEducationToBackend">确 定</el-button>
          <el-button @click="addEducationVisible = false">取消</el-button>
        </span>
      </el-dialog>
      <div id="educate" v-for="(educate, index) in education">
        <div>
          <el-button type="primary" class="edit-button" plain @click="openEditEducationDialog(index)">编辑</el-button>
          <el-dialog title="教育经历" :visible.sync="editEducationVisible" center>
            <el-form :model="editEducation">
              <el-form-item label="就读学校" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editEducation.school"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="学历" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editEducation.educationDegree"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="所学专业" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editEducation.major"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="就读时间" :label-width="'120px'">
                <el-date-picker
                    v-model="editEducation.educationStart"
                    type="date">
                </el-date-picker>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <el-date-picker
                    v-model="editEducation.educationEnd"
                    type="date">
                </el-date-picker>
              </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="editEducationToBackend">确 定</el-button>
          <el-button @click="editEducationVisible = false">取消</el-button>
        </span>
          </el-dialog>
        </div>
        <div id="schoolName">
          {{educate.school}}
        </div>
        <br>
        学位：{{educate.educationDegree}}
        <br>
        <br>
        所学专业：{{educate.major}}
        <br>
        <div>
          <el-button type="danger" icon="el-icon-delete" circle class="edit-button" @click="deleteEducation(index)"></el-button>
        </div>
        <br>
        开始日期：{{educate.educationStart}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        结束日期：{{educate.educationEnd }}
      </div>
    </el-main>

    <el-main id="work">
      <h1><i class="el-icon-s-data"></i> 工作经历</h1>
      <el-button type="primary" round @click="addWorkVisible = true">添加工作经历</el-button>
      <el-dialog title="工作经历" :visible.sync="addWorkVisible" center>
        <el-form :model="addWork">
          <el-form-item label="企业名称" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addWork.workEnterprise" placeholder="输入企业名称"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="工作职位" :label-width="'120px'">
            <el-cascader
                placeholder="选择职位"
                :options="industry"
                v-model="addWork.workOccupation"
                :key="industry.industryId"
                :label="industry.industryName"
                :children="industry.categories"
                :show-all-levels="false"
                filterable
                @change="handleCategoryChange"
            ></el-cascader>
          </el-form-item>
          <el-form-item label="所属部门" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addWork.workSector" placeholder="输入所属部门"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="工作内容" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addWork.workDescription" placeholder="输入工作内容"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="工作业绩" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addWork.workAchievement" placeholder="输入工作业绩"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="工作时间" :label-width="'120px'">
            <el-date-picker
                v-model="addWork.workStart"
                type="date"
                placeholder="选择开始日期">
            </el-date-picker>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <el-date-picker
                v-model="addWork.workEnd"
                type="date"
                placeholder="选择结束日期">
            </el-date-picker>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="addWorkToBackend">确 定</el-button>
          <el-button @click="addWorkVisible = false">取消</el-button>
        </span>
      </el-dialog>
      <div id="job" v-for="(job, index) in work">
        <div>
          <el-button type="primary" class="edit-button" plain @click="openEditWorkDialog(index)">编辑</el-button>
          <el-dialog title="工作经历" :visible.sync="editWorkVisible" center>
            <el-form :model="editWork">
              <el-form-item label="企业名称" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editWork.workEnterprise"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="工作职位" :label-width="'120px'">
                <el-cascader
                    :options="industry"
                    v-model="editWork.workOccupation"
                    :key="industry.industryId"
                    :label="industry.industryName"
                    :children="industry.categories"
                    :show-all-levels="false"
                    filterable
                    @change="handleCategoryChange"
                ></el-cascader>
              </el-form-item>
              <el-form-item label="所属部门" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editWork.workSector"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="工作内容" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editWork.workDescription"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="工作业绩" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editWork.workAchievement"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="工作时间" :label-width="'120px'">
                <el-date-picker
                    v-model="editWork.workStart"
                    type="date">
                </el-date-picker>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <el-date-picker
                    v-model="editWork.workEnd"
                    type="date">
                </el-date-picker>
              </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="editWorkToBackend">确 定</el-button>
          <el-button @click="editWorkVisible = false">取消</el-button>
        </span>
          </el-dialog>
        </div>
        <div id="company">
          {{job.workEnterprise}}
        </div>
        <br>
        工作职位：{{job.workOccupationName}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        所属部门：{{job.workSector}}
        <br>
        <br>
        工作内容：{{job.workDescription}}
        <br>
        <br>
        工作业绩：{{job.workAchievement}}
        <br>
        <div>
          <el-button type="danger" icon="el-icon-delete" circle class="edit-button" @click="deleteWork(index)"></el-button>
        </div>
        <br>
        工作日期：{{job.workStart}} ~ {{job.workEnd}}
      </div>
    </el-main>

    <el-main id="project">
      <h1><i class="el-icon-s-order"></i> 项目经历</h1>
      <el-button type="primary" round @click="addProjectVisible = true">添加项目经历</el-button>
      <el-dialog title="项目经历" :visible.sync="addProjectVisible" center>
        <el-form :model="addProject">
          <el-form-item label="项目名称" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addProject.projectName" placeholder="输入项目名称"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="项目角色" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addProject.projectRole" placeholder="输入项目角色"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="项目链接" :label-width="'120px'">
            <el-col span="12">
              <el-input v-model="addProject.projectLink" placeholder="输入项目链接"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="项目描述" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addProject.projectDescription" placeholder="输入项目描述"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="项目成绩" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addProject.projectAchievement" placeholder="输入项目成绩"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="项目时间" :label-width="'120px'">
            <el-date-picker
                v-model="addProject.projectStart"
                type="date"
                placeholder="选择开始日期">
            </el-date-picker>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <el-date-picker
                v-model="addProject.projectEnd"
                type="date"
                placeholder="选择结束日期">
            </el-date-picker>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="addProjectToBackend">确 定</el-button>
          <el-button @click="addProjectVisible = false">取消</el-button>
        </span>
      </el-dialog>
      <div id="projectExp" v-for="(projectExp, index) in project">
        <div>
          <el-button type="primary" class="edit-button" plain @click="openEditProjectDialog(index)">编辑</el-button>
          <el-dialog title="项目经历" :visible.sync="editProjectVisible" center>
            <el-form :model="editProject">
              <el-form-item label="项目名称" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editProject.projectName"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="项目角色" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editProject.projectRole"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="项目链接" :label-width="'120px'">
                <el-col span="12">
                  <el-input v-model="editProject.projectLink"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="项目描述" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editProject.projectDescription"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="项目成绩" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editProject.projectAchievement"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="项目时间" :label-width="'120px'">
                <el-date-picker
                    v-model="editProject.projectStart"
                    type="date">
                </el-date-picker>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <el-date-picker
                    v-model="editProject.projectEnd"
                    type="date">
                </el-date-picker>
              </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="editProjectToBackend">确 定</el-button>
          <el-button @click="editProjectVisible = false">取消</el-button>
        </span>
          </el-dialog>
        </div>
        <div id="projectName">
          {{projectExp.projectName}}
        </div>
        <br>
        项目角色：{{projectExp.projectRole}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        项目链接：{{projectExp.projectLink}}
        <br>
        <br>
        项目描述：{{projectExp.projectDescription}}
        <br>
        <br>
        项目成绩：{{projectExp.projectAchievement}}
        <br>
        <div>
          <el-button type="danger" icon="el-icon-delete" circle class="edit-button" @click="deleteProject(index)"></el-button>
        </div>
        <br>
        项目日期：{{projectExp.projectStart}} ~ {{projectExp.projectEnd}}
      </div>
    </el-main>

    <el-main id="qualification">
      <h1><i class="el-icon-s-marketing"></i> 资格证书</h1>
      <el-button type="primary" round @click="addQualificationVisible = true">添加资格证书</el-button>
      <el-dialog title="资格证书" :visible.sync="addQualificationVisible" center>
        <el-form :model="addQualification">
          <el-form-item label="资格证书名称" :label-width="'120px'">
            <el-col span="8">
              <el-input v-model="addQualification.qualificationName" placeholder="输入资格证书名称"></el-input>
            </el-col>
          </el-form-item>
          <el-form-item label="获得日期" :label-width="'120px'">
            <el-date-picker
                v-model="addQualification.qualificationTime"
                type="date"
                placeholder="选择获得日期">
            </el-date-picker>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="addQualificationToBackend">确 定</el-button>
          <el-button @click="addQualificationVisible = false">取消</el-button>
        </span>
      </el-dialog>
      <div id="qualify" v-for="(qualify,index) in qualification">
        <div>
          <el-button type="primary" class="edit-button" plain @click="openEditQualificationDialog(index)">编辑</el-button>
          <el-dialog title="资格证书" :visible.sync="editQualificationVisible" center>
            <el-form :model="editQualification">
              <el-form-item label="资格证书名称" :label-width="'120px'">
                <el-col span="8">
                  <el-input v-model="editQualification.qualificationName"></el-input>
                </el-col>
              </el-form-item>
              <el-form-item label="获得日期" :label-width="'120px'">
                <el-date-picker
                    v-model="editQualification.qualificationTime"
                    type="date">
                </el-date-picker>
              </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="editQualificationToBackend">确 定</el-button>
          <el-button @click="editQualificationVisible = false">取消</el-button>
        </span>
          </el-dialog>
        </div>
        <div id="qualificationName">
          {{qualify.qualificationName}}
        </div>
        <br>
        <div>
          <el-button type="danger" icon="el-icon-delete" circle class="edit-button" @click="deleteQualification(index)"></el-button>
        </div>
        获得日期：{{qualify.qualificationTime}}
      </div>
    </el-main>

    <el-main id="strength">
      <h1><i class="el-icon-s-opportunity"></i> 个人优势</h1>
      <div>
        <el-button type="primary" class="edit-button" plain @click="openEditResumeDialog">编辑</el-button>
        <el-dialog title="个人优势" :visible.sync="editResumeVisible" center>
          <el-form :model="editResume">
            <el-form-item label="个人优势" :label-width="'120px'">
              <el-input v-model="editResume.strength" type="textarea" :rows="4"></el-input>
            </el-form-item>
          </el-form>
          <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="editResumeToBackend">确 定</el-button>
      <el-button @click="editResumeVisible = false">取消</el-button>
    </span>
        </el-dialog>
      </div>
      <div id="strength">
        {{strength}}
      </div>
    </el-main>

  </el-container>

</template>

<script>
export default {
  data() {
    return {
      //以下为查询信息所需data
      seekerId: 0,
      seeker: [],
      seekerCity: '',
      seekerHomeTown: '',
      intention: [],
      education: [],
      work: [],
      project: [],
      qualification: [],
      strength: '',

      //以下为增删改数据所需data
      formData: {
        city: '0',
        province: '0',
        salary: '0',
        degree: '0',
        experience: '0',
        category: '0',
        nature: '0',
        scale: '0'
      },
      province: {
        value: '',
        label: '',
        children: {
          value: '',
          label: ''
        }
      },
      home: {
        value: '',
        label: '',
        children: {
          value: '',
          label: ''
        }
      },
      industry: {
        value: '',
        label: '',
        children: {
          value: '',
          label: ''
        }
      },
      // 修改个人信息
      editSeekerVisible: false,
      editSeeker: {
        seekerId: 0,
        seekerName: '',
        password: '',
        seekerGender: '',
        seekerBirthday: '',
        seekerLocation: 0,
        seekerHome: 0,
        tel: '',
        seekerWechat: '',
        seekerEmail: ''
      },
      //增加求职意向
      addIntentionVisible: false,
      addIntention: {
        intentionId: null,
        intentionOccupation: 0,
        intentionCity: 0,
        intentionSalary: '',
        intentionResume: 0
      },
      //修改求职意向
      editIntentionVisible: false,
      editIntention: {
        intentionId: null,
        intentionOccupation: 0,
        intentionCity: 0,
        intentionSalary: '',
        intentionResume: 0
      },
      //增加教育经历
      addEducationVisible: false,
      addEducation: {
        educationId: null,
        school: '',
        educationDegree: '',
        major: '',
        educationStart: '',
        educationEnd: '',
        educationResume: 0
      },
      // 修改教育经历
      editEducationVisible: false,
      editEducation: {
        educationId: null,
        school: '',
        educationDegree: '',
        major: '',
        educationStart: '',
        educationEnd: '',
        educationResume: 0
      },
      //增加工作经历
      addWorkVisible: false,
      addWork: {
        workId: null,
        workEnterprise: '',
        workOccupation: 0,
        workSector: '',
        workDescription: '',
        workAchievement: '',
        workStart: '',
        workEnd: '',
        workResume: 0
      },
      editWorkVisible: false,
      editWork: {
        workId: null,
        workEnterprise: '',
        workOccupation: 0,
        workSector: '',
        workDescription: '',
        workAchievement: '',
        workStart: '',
        workEnd: '',
        workResume: 0
      },
      //增加项目经历
      addProjectVisible: false,
      addProject: {
        projectId: null,
        projectName: '',
        projectRole: '',
        projectLink: '',
        projectDescription: '',
        projectAchievement: '',
        projectStart: '',
        projectEnd: '',
        projectResume: 0
      },
      // 修改项目经历
      editProjectVisible: false,
      editProject: {
        projectId: null,
        projectName: '',
        projectRole: '',
        projectLink: '',
        projectDescription: '',
        projectAchievement: '',
        projectStart: '',
        projectEnd: '',
        projectResume: 0
      },
      //增加资格证书
      addQualificationVisible: false,
      addQualification: {
        qualificationId: null,
        qualificationName: '',
        qualificationTime: '',
        qualificationResume: 0
      },
      // 修改资格证书
      editQualificationVisible: false,
      editQualification: {
        qualificationId: null,
        qualificationName: '',
        qualificationTime: '',
        qualificationResume: 0
      },
      // 修改个人优势
      editResumeVisible: false,
      editResume: {
        resumeId: 0,
        strength: '',
        resumeSeeker: 0
      },

    }
  },
  created() {
    // 在组件创建时获取传递过来的id值
    this.seekerId = this.$route.query.id;
    this.fetchSeekerById();
  },
  mounted() {
    this.$axios.post('/city/allProvinceCity').then((resp) => {
      this.province = resp.data
      this.home = resp.data
    })
    this.$axios.post('/category/allIndustryCategory').then((resp) => {
      this.industry = resp.data
    })
  },
  methods:{
    //求职者
    fetchSeekerById() { //求职者信息
      this.$axios.get("/seeker/getSeekerById?seekerId="+this.seekerId).then(resp=>{
        this.seeker = resp.data
        if (this.seeker.length > 0) { //后执行
          this.fetchLocationById()
          this.fetchHomeById()
          this.fetchIntentionById()
          this.fetchEducationById()
          this.fetchWorkById()
          this.fetchProjectById()
          this.fetchQualificationById()
          this.fetchStrengthById()
        }
      })
    },
    calculateAge(birthday) { //计算年龄
      const birthDate = new Date(birthday);
      const today = new Date();
      let age = today.getFullYear() - birthDate.getFullYear();
      const monthDifference = today.getMonth() - birthDate.getMonth();
      if (monthDifference < 0 || (monthDifference === 0 && today.getDate() < birthDate.getDate())) {
        age--;
      }
      return age;
    },
    fetchLocationById() { //求职者所在地
      this.$axios.get("/city/getCityNameById?cityId="+this.seeker[0].seekerLocation).then(resp=>{
        this.seekerCity = resp.data
      })
    },
    fetchHomeById() { //求职者籍贯
      this.$axios.get("/city/getCityNameById?cityId="+this.seeker[0].seekerHome).then(resp=>{
        this.seekerHomeTown = resp.data
      })
    },

    //求职意向
    fetchIntentionById() { //求职意向信息
      this.$axios.get("/intention/getIntentionById?intentionResume="+this.seekerId).then(resp=>{
        this.intention = resp.data
        if (this.intention.length > 0) {
          this.fetchIntentionCityNames()
          this.fetchIntentionCategoryNames()
        }
      })
    },
    fetchIntentionCityNames() { //查找意向城市
      this.intention.forEach(intend => { //循环
        this.$axios.get("/city/getCityNameById?cityId=" + intend.intentionCity).then(resp => {
          this.$set(intend, 'intentionCityName', resp.data);
        });
      });
    },
    fetchIntentionCategoryNames() { //查找意向职位
      this.intention.forEach(intend => { //循环
        this.$axios.get("/category/getCategoryNameById?categoryId=" + intend.intentionOccupation).then(resp => {
          this.$set(intend, 'intentionOccupationName', resp.data);
        });
      });
    },

    //教育经历
    fetchEducationById() { //教育经历信息
      this.$axios.get("/education/getEducationById?educationResume="+this.seekerId).then(resp=>{
        this.education = resp.data
      })
    },

    //工作经历
    fetchWorkById() { //工作经历信息
      this.$axios.get("/work/getWorkById?workResume="+this.seekerId).then(resp=>{
        this.work = resp.data
        if (this.work.length > 0) {
          this.fetchWorkCategoryNames()
        }
      })
    },
    fetchWorkCategoryNames() { //查找工作职位
      this.work.forEach(job => { //循环
        this.$axios.get("/category/getCategoryNameById?categoryId=" + job.workOccupation).then(resp => {
          this.$set(job, 'workOccupationName', resp.data);
        });
      });
    },

    //项目经历
    fetchProjectById() { //教育经历信息
      this.$axios.get("/project/getProjectById?projectResume="+this.seekerId).then(resp=>{
        this.project = resp.data
      })
    },

    //资格证书
    fetchQualificationById() { //资格证书信息
      this.$axios.get("/qualification/getQualificationById?qualificationResume="+this.seekerId).then(resp=>{
        this.qualification = resp.data
      })
    },

    //个人优势
    fetchStrengthById() { //个人优势
      this.$axios.get("/resume/getStrengthById?resumeSeeker="+this.seekerId).then(resp=>{
        this.strength = resp.data
      })
    },

    //用于表单
    handleCityChange(value) {
      this.formData.city = value
      this.$message(value)
      this.submitForm()
      this.$store.commit('setSeekerFilterSelect', this.formData)
    },
    handleProvinceChange(value) {
      this.formData.province = value[value.length - 1]
      this.editIntention.intentionCity = this.formData.province
      this.$message('选择成功')
      this.submitForm()
      this.$store.commit('setSeekerFilterSelect', this.formData)
    },
    handleHomeChange(value) {
      this.editSeeker.seekerHome = value[value.length - 1];
    },
    handleLocationChange(value) {
      this.editSeeker.seekerLocation = value[value.length - 1];
    },
    handleCategoryChange(value) {
      this.formData.category = value[value.length - 1]
      this.editIntention.intentionOccupation = this.formData.category
      this.editWork.workOccupation = this.formData.category
      this.$message('选择成功')
      this.submitForm()
      this.$store.commit('setSeekerFilterSelect', this.formData)
    },
    submitForm() {
      this.$axios
          .post('occupation/occupationSearch', this.formData)
          .catch((error) => {
            this.$message.error('Failed to submit data.')
          })
    },

    //添加求职意向
    addIntentionToBackend() {
      this.addIntention.intentionResume = this.seekerId
      this.addIntention.intentionOccupation = this.formData.category
      this.addIntention.intentionCity = this.formData.province
      this.$axios.post('/intention/addIntention', this.addIntention)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('求职意向添加成功');
              this.addIntentionVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //添加教育经历
    addEducationToBackend() {
      this.addEducation.educationResume = this.seekerId
      this.$axios.post('/education/addEducation', this.addEducation)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('教育经历添加成功');
              this.addEducationVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //添加工作经历
    addWorkToBackend() {
      this.addWork.workResume = this.seekerId
      this.addWork.workOccupation = this.formData.category
      this.$axios.post('/work/addWork', this.addWork)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('工作经历添加成功');
              this.addWorkVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //添加工作经历
    addProjectToBackend() {
      this.addProject.projectResume = this.seekerId
      this.$axios.post('/project/addProject', this.addProject)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('项目经历添加成功');
              this.addProjectVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //添加资格证书
    addQualificationToBackend() {
      this.addQualification.qualificationResume = this.seekerId
      this.$axios.post('/qualification/addQualification', this.addQualification)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('资格证书添加成功');
              this.addQualificationVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //修改求职意向
    openEditIntentionDialog(index) {
      // 将选中的求职意向信息赋值给 editIntention
      this.editIntention = {
        intentionId: this.intention[index].intentionId,
        intentionOccupation: this.intention[index].intentionOccupation,
        intentionCity: this.intention[index].intentionCity,
        intentionSalary: this.intention[index].intentionSalary,
        intentionResume: this.intention[index].intentionResume
      };
      this.editIntentionVisible = true;
    },
    editIntentionToBackend() {
      this.$axios.post('/intention/updateIntentionById', this.editIntention)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('求职意向更新成功');
              this.editIntentionVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //修改教育经历
    openEditEducationDialog(index) {
      // 将选中的教育经历信息赋值给 editEducation
      this.editEducation = {
        educationId: this.education[index].educationId,
        school: this.education[index].school,
        educationDegree: this.education[index].educationDegree,
        major: this.education[index].major,
        educationStart: this.education[index].educationStart,
        educationEnd: this.education[index].educationEnd,
        educationResume: this.education[index].educationResume
      };
      this.editEducationVisible = true;
    },
    editEducationToBackend() {
      this.$axios.post('/education/updateEducationById', this.editEducation)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('教育经历更新成功');
              this.editEducationVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //修改工作经历
    openEditWorkDialog(index) {
      // 将选中的工作经历信息赋值给 editWork
      this.editWork = {
        workId: this.work[index].workId,
        workEnterprise: this.work[index].workEnterprise,
        workOccupation: this.work[index].workOccupation,
        workSector: this.work[index].workSector,
        workDescription: this.work[index].workDescription,
        workAchievement: this.work[index].workAchievement,
        workStart: this.work[index].workStart,
        workEnd: this.work[index].workEnd,
        workResume: this.work[index].workResume
      };
      this.editWorkVisible = true;
    },
    editWorkToBackend() {
      this.$axios.post('/work/updateWorkById', this.editWork)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('工作经历更新成功');
              this.editWorkVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //修改项目经历
    openEditProjectDialog(index) {
      // 将选中的项目经历信息赋值给 editProject
      this.editProject = {
        projectId: this.project[index].projectId,
        projectName: this.project[index].projectName,
        projectRole: this.project[index].projectRole,
        projectLink: this.project[index].projectLink,
        projectDescription: this.project[index].projectDescription,
        projectAchievement: this.project[index].projectAchievement,
        projectStart: this.project[index].projectStart,
        projectEnd: this.project[index].projectEnd,
        projectResume: this.project[index].projectResume
      };
      this.editProjectVisible = true;
    },
    editProjectToBackend() {
      this.$axios.post('/project/updateProjectById', this.editProject)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('项目经历更新成功');
              this.editProjectVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //修改资格证书
    openEditQualificationDialog(index) {
      // 将选中的资格证书信息赋值给 editQualification
      this.editQualification = {
        qualificationId: this.qualification[index].qualificationId,
        qualificationName: this.qualification[index].qualificationName,
        qualificationTime: this.qualification[index].qualificationTime,
        qualificationResume: this.qualification[index].qualificationResume
      };
      this.editQualificationVisible = true;
    },
    editQualificationToBackend() {
      this.$axios.post('/qualification/updateQualificationById', this.editQualification)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('资格证书更新成功');
              this.editQualificationVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //修改个人优势
    openEditResumeDialog() {
      // 将选中的个人优势信息赋值给 editResume
      this.editResume = {
        resumeId: this.seekerId,
        strength: this.strength,
        resumeSeeker: this.seekerId
      };
      this.editResumeVisible = true;
    },
    editResumeToBackend() {
      this.$axios.post('/resume/updateResumeById', this.editResume)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('个人优势更新成功');
              this.editResumeVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //修改个人信息
    openEditSeekerDialog(index) {
      // 将选中的个人信息赋值给 editSeeker
      this.editSeeker = {
        seekerId: this.seekerId,
        seekerName: this.seeker[index].seekerName,
        password: this.seeker[index].password,
        seekerGender: this.seeker[index].seekerGender,
        seekerBirthday: this.seeker[index].seekerBirthday,
        seekerLocation: this.seeker[index].seekerLocation,
        seekerHome: this.seeker[index].seekerHome,
        tel: this.seeker[index].tel,
        seekerWechat: this.seeker[index].seekerWechat,
        seekerEmail: this.seeker[index].seekerEmail
      };
      this.editSeekerVisible = true;
      console.log(this.seeker)
      console.log(this.editSeeker)
    },
    editSeekerToBackend() {
      console.log(this.editSeeker)
      this.$axios.post('/seeker/updateSeekerById', this.editSeeker)
          .then(response => {
            if (response.data === 1) {
              this.$message.success('个人信息更新成功');
              this.editSeekerVisible = false; // 关闭对话框
              location.reload(); // 刷新页面
            }
          })
    },
    //删除求职意向
    deleteIntention(index) {
      // 调用后端 API 删除求职意向
      this.$axios.post('/intention/deleteIntentionById', { intentionId: this.intention[index].intentionId })
          .then(response => {
            if (response.data === 1) {
              this.$message.success('求职意向删除成功');
              location.reload(); // 刷新页面
            }
          })
    },
    //删除教育经历
    deleteEducation(index) {
      // 调用后端 API 删除求职意向
      this.$axios.post('/education/deleteEducationById', { educationId: this.education[index].educationId })
          .then(response => {
            if (response.data === 1) {
              this.$message.success('教育经历删除成功');
              location.reload(); // 刷新页面
            }
          })
    },
    //删除工作经历
    deleteWork(index) {
      // 调用后端 API 删除求职意向
      this.$axios.post('/work/deleteWorkById', { workId: this.work[index].workId })
          .then(response => {
            if (response.data === 1) {
              this.$message.success('工作经历删除成功');
              location.reload(); // 刷新页面
            }
          })
    },
    //删除项目经历
    deleteProject(index) {
      // 调用后端 API 删除求职意向
      this.$axios.post('/project/deleteProjectById', { projectId: this.project[index].projectId })
          .then(response => {
            if (response.data === 1) {
              this.$message.success('项目经历删除成功');
              location.reload(); // 刷新页面
            }
          })
    },
    //删除资格证书
    deleteQualification(index) {
      // 调用后端 API 删除求职意向
      this.$axios.post('/qualification/deleteQualificationById', { qualificationId: this.qualification[index].qualificationId })
          .then(response => {
            if (response.data === 1) {
              this.$message.success('资格证书删除成功');
              location.reload(); // 刷新页面
            }
          })
    },

  }

}
</script>

<style  scoped>
#Resume {
  border: 1px;
  border-radius: 4px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
}
.el-main {
  width: 80%;
  border: 1px;
  border-radius: 4px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  text-align: left;
  padding-top: 1px;
  padding-bottom: 30px;
  margin: 30px auto;
}
h1{
  font-family: "Hiragino Sans GB", sans-serif;
  font-size: 25px;
}
#seekerInfo {
  word-spacing: 5em;
}
#intend, #educate, #job, #projectExp, #qualify{
  width: 80%;
  border: 1px;
  border-radius: 4px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  margin: 20px 1px;
  padding: 20px 20px;
}
#seekerName, #intentionOccupationName, #schoolName, #company, #projectName, #qualificationName, #strength{
  font-size: 20px;
}
.edit-button {
  float: right;
}

</style>
